#pragma once

#include<iostream>

using namespace std;

class Task
{
public:
  Task()
  {}

  Task(int x,int y,char op)
    :_x(x)
    ,_y(y)
    ,_op(op)
    ,_exit_code(0)
  {}

  void operator()()
  {
    switch(_op)
    {
      case '+':
        _result = _x + _y;
        break;

      case '-':
        _result = _x - _y;
        break;

      case '*':
        _result = _x * _y;
        break;

      case '/':
      {
        if(_y == 0)
          _exit_code = 0;
        else
          _result = _x / _y;
      } 
      break;

      case '%':
      {
        if(_y == 0)
          _exit_code = 0;
        else
          _result = _x / _y;
      }

      default:
        break;
    }
  }

  string FormatArg() {return to_string(_x) + _op + to_string(_y) + "= ?";}

  string FormatRes() {return to_string(_x) + _op + to_string(_y) + " = " + to_string(_result) + "(" + to_string(_exit_code) + ")";}

  ~Task()
  {}

private:
  int _x;
  int _y;
  char _op;
  int _result;
  int _exit_code;
};
